//Accepted
//11805 - Bafana Bafana
#include <cstdio>

int t, n, k, p, x=1;

int main(){
scanf("%d", &t);

while(t--){
	scanf("%d%d%d", &n, &k, &p);
	printf("Case %d: %d\n", x++, ((k+p-1)%n)+1  );
}


return 0;
}

